// 配置仓库

import axios from 'axios'
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import type { ChannelItem, ChannelResData } from '@/types/data'

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)
  const add = () =>count.value++
  const cut = () =>count.value--

  const channelList = ref<ChannelItem[]>([])
  const getChannelList = async ()=>{
    const res = await axios.get<ChannelResData>(
      "http://geek.itheima.net/v1_0/channels"
    );
    channelList.value = res.data.data.channels
  }
  return { count, doubleCount, add, cut,getChannelList,channelList}
})
